home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / OTPLASMA.ZIP / plasma.doc < prev   
Text File  |  1996-06-20  |  6KB  |  118 lines

  1.  
  2.                      - THE OUTLAW TRIAD DEMO-SERIES -
  3.  
  4. ────────────────────────────────■ PART VII ■───────────────────────────────────
  5.  
  6.                          Written by : Vulture/OT
  7.                          Code in    : Assembler
  8.                          Topic      : Plasmas
  9.  
  10. ──────────────────────────────■ Introduction ■─────────────────────────────────
  11.  
  12.  Welcome to the Outlaw Triad demo-series! In these series we will be talking
  13.  about programming demo-effects in either pascal or assembler. Theory behind
  14.  the effects shall be discussed while a full sourcecode is also provided.
  15.  This time a VERY wellknown type of effect is discussed and that is plasmas!
  16.  Plasmas are great for background effects. For example, when displaying some
  17.  text, you could run a plasma screen in the background. Let's see how plasma
  18.  screens are made. Enjoy!
  19.  
  20. ─────────────────────────────────■ Theory ■────────────────────────────────────
  21.  
  22.  Note: I know plasmas are very old and shouldn't be used too much nowadays
  23.  but I think plasmas are great for learning purposes. That's the reason why
  24.  I decided to put a plasma trainer into these series anyway.
  25.  
  26.  Let's start by mentioning the diverence between 2 sorts of plasmas. Static
  27.  plasma and realtime plasma. The first variant simply creates a screen on
  28.  which pixels fluently flow into other colors. Then the palette is rotated.
  29.  Realtime plasma uses cosine values to create magnificient curves on the vga
  30.  thus being much more fun to watch than static plasma, IMHO. But, realtime
  31.  plasma is more time consuming than static plasma because each pixel on the
  32.  screen has to be refreshed each frame!
  33.  
  34.  To create a plasma screen you should use an unchained tweaked vga mode.
  35.  Because every pixel on the screen is affected each frame, it is usually
  36.  best to reprogram the vga to a mode in which you have large pixels, let's
  37.  say 4x4. This will result in mode 80x50 so we only have to process 80*50=
  38.  4000 pixels each frame. Also create a good palette. The colors should run
  39.  smoothly from one to the other.
  40.  
  41.  To create realtime plasma, we need cosine values. Why? Because cosine values
  42.  represent a nice curve and that's what we want, nice curves. Take a look at
  43.  the source to see a good cosine chart. Oh, that chart was generated by Jare/
  44.  VangelisTeam (always give credit where credit is due), but it's pretty easy
  45.  to generate your own charts. The values in this example range from 0 to 64
  46.  but of course you can go and experiment with other values/ranges. The range
  47.  in this example is pretty clever. Think about it! When you add 4 cosine
  48.  values in range 0..64, the maximum value you can get is 4*64=256. And that's
  49.  the exact amount of colors we have to our disposal in plain mode 13h.
  50.  In this example I only used 128 colors. The cosine values go up to 64 so I
  51.  had to implement code to handle additions above 128.
  52.  
  53.  Anyway, now we have setup our vga and created a good cosine chart. Let's go
  54.  and code the plasma. We want complex curves on the screen. To create plasma
  55.  screens, we simply add 4 cosine values and put the resulting value on the
  56.  vga. We use 2 cosine values for vertical movement and 2 for the horizontal
  57.  movement. For each frame we use 4 pointers to the cosine chart. For each
  58.  horizontal pixel, we update our 2 horizontal cosine pointers to point to
  59.  another cosine value in the chart! For each horizontal line we go down we
  60.  update our 2 vertical pointers. When updating the pointers, don't save the
  61.  new values to the pointer variables but into temporary variables (in asm I
  62.  just used some registers). We update the original pointers when we've done
  63.  the entire screen (frame). Complex? Observe this:
  64.  
  65.      - Set vertical cosine start values (save into temp variables)
  66.      - Go into vertical loop (50 times in this example)
  67.         - Set horizontal cosine start values (save into temp variables)
  68.         - Go into horizontal loop (80 times in this example)
  69.            - Add 4 temporary cosine values
  70.            - Put result on vga
  71.            - Update the temporary horizontal cosine values
  72.         - End horizontal loop
  73.         - Update the temporary vertical cosine values
  74.      - End vertical loop
  75.      - Update the original cosine start values
  76.      - Back to start
  77.  
  78.  Just take a look at the source to see what I mean. Go and change some of the
  79.  values and see what happens. Also, try to implement this in hi-resolutions
  80.  to see what you get. Allthough it's a rather old effect, it still is good
  81.  enough to put in demos when you use it clever enough. I know this text is
  82.  a bit cryptic but once you've experimented with the source, all will become
  83.  clear. Trust me ... I know ... :-)
  84.  
  85.  Ok, this is all for now. Happy coding!
  86.  
  87.      -Vulture/Outlaw Triad-
  88.  
  89. ───────────────────────────────■ Distro Sites ■────────────────────────────────
  90.  
  91.  Call our distrobution sites! All our releases are available at:
  92.  
  93.   BlueNose      World HQ          +31 (0)345-619401
  94.   The Force     Distrosite        +31 (0)36-5346967    More distros wanted!
  95.   Bugs'R'Us     Distrosite        +31 (0)252-686092    (preferably outside
  96.   MagicWare     Italian HQ        +39  6-52355532       of The Netherlands)
  97.   ShockWave     South African HQ  +27 (011)888-6345
  98.   Society HQ    United States HQ  +1  (518)465-6721
  99.  
  100.  Also check the major FTP sites for Outlaw Triad productions.
  101.  
  102. ──────────────────────────────────■ Contact ■──────────────────────────────────
  103.  
  104.  Want to contact Outlaw Triad for some reason? You can reach us at our
  105.  distrosites in Holland. Or if you have e-mail access, mail us:
  106.  
  107.    Vulture   (coder/pr)   comma400@tem.nhl.nl
  108.  
  109.  Our internet homepage:
  110.  
  111.    http://www.tem.nhl.nl/~comma400/vulture.html
  112.  
  113.  These internet adresses should be valid at least till june 1997.
  114.  
  115. ──────────────────────────────────────────────────────────────────────────────
  116.  
  117.         Quote: It is dangerous to be sincere unless you are also stupid.
  118.